package com.park.user.controller.licenseplate;

import com.park.controller.BaseController;
import com.park.entity.licenseplate.LicensePlateDto;
import com.park.response.Result;
import com.park.user.anno.UserToken;
import com.park.user.service.licenseplate.UserLicensePlateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 * @title: UserLicensePlate
 * @projectName park
 * @description: 车牌
 * @date 2020/5/211:45
 */
@RestController
@RequestMapping(value = "/wx/licenseplate")
public class UserLicensePlateController extends BaseController {

    @Autowired
    private UserLicensePlateService userLicensePlateService;

    //添加车牌
    @UserToken
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public Result addLicenseplate(@RequestBody LicensePlateDto licensePlateDto){
        licensePlateDto.setUserid(getUserId());
        userLicensePlateService.addLicenseplate(licensePlateDto);
        return SUCCESS();
    }

    //查询是否绑定车牌
    @UserToken
    @RequestMapping(value = "/query",method = RequestMethod.POST)
    public Result queryLicenseplate(){
        LicensePlateDto licensePlateDto = userLicensePlateService.queryLicenseplate(getUserId());
        return SUCCESS(licensePlateDto);
    }

    //修改车牌
    @UserToken
    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    public Result editLicenseplate(@RequestBody LicensePlateDto licensePlateDto){
        licensePlateDto.setUserid(getUserId());
        userLicensePlateService.editLicenseplate(licensePlateDto);
        return SUCCESS();
    }

    //解除绑定
    @UserToken
    @RequestMapping(value = "/del",method = RequestMethod.POST)
    public Result delLicenseplate(){
        Integer userId = getUserId();
        userLicensePlateService.delLicenseplate(userId);
        return SUCCESS();
    }
}
